<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>正在跳转...</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="/addon/sanhai-redirect/redirect.css">
    <style>
        body {
            background-color: #f8f9fa;
            height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
        }
    </style>
</head>
<body>
    <div class="redirect-container">
        <div class="spinner-border text-primary" role="status">
            <span class="visually-hidden">Loading...</span>
        </div>
        <h2 class="mb-3">正在跳转到备用站</h2>
        <p class="mb-4">您访问的页面已自动跳转到 <strong>sanhaioj.longzhuge.com.cn</strong></p>
        <p class="mb-4">
            如果您的浏览器没有自动跳转，请点击下面的链接：
            <br>
            <a href="{{ redirect_url }}" class="btn btn-primary mt-2">手动跳转</a>
        </p>
        <div class="redirect-url">{{ redirect_url }}</div>
        <p class="text-muted">
            <span class="countdown" id="countdown">5</span> 秒后自动跳转...
        </p>


        <div class="progress">
            <div class="progress-bar progress-bar-striped progress-bar-animated bg-primary" 
                 role="progressbar" 
                 style="width: 100%" 
                 aria-valuenow="100" 
                 aria-valuemin="0" 
                 aria-valuemax="100"></div>
        </div>
    </div>

    <script>

        let seconds = 5;
        const countdownEl = document.getElementById('countdown');
        const progressBar = document.querySelector('.progress-bar');

        const interval = setInterval(() => {
            seconds--;
            countdownEl.textContent = seconds;


            const progress = (seconds / 5) * 100;
            progressBar.style.width = `${progress}%`;
            progressBar.setAttribute('aria-valuenow', progress);

            if (seconds <= 0) {
                clearInterval(interval);
                window.location.href = "{{ redirect_url }}";
            }
        }, 1000);


        document.querySelector('.btn-primary').addEventListener('click', () => {
            clearInterval(interval);
        });
    </script>
</body>
</html>
